/****************************************************************************
 * system task
 * Tested MCU 
 * Owner : apleilx
 * **************************************************************************/
#define _SYSTASK_MODULE_

#include "systask.h"

#include "board.h"
#include "fsl_gpio.h"
#include "clock_config.h"
#include "pin_mux.h"

#include "osObjects.h" 

void sys_init(void);

/*****************************************************************************//*!
*
* @brief   SysInit
*            
* @param   none
*
* @return  none
*
* @ Pass/ Fail criteria: none
*****************************************************************************/
void sys_task (void   *argument)
{
    sys_init();
    
    while(1)
    {
        osDelay(5);
        
        PulseCreat( &sysst.pulse, sysst.g_uTicks);
        
        if(sysst.pulse.bPulse_1s)
            TimeRun(&sysst.time);
        
        sysst.bcd_time = time_to_bcd(&sysst.time);
        sysst.sig_time = time_to_sig(&sysst.time);
    }
}


#include "mbapp.h"
/*******************************************************************************
 * tick isr
 ******************************************************************************/
void App_SysTick_Handler(void)
{
    sysst.g_uTicks +=2;
    mbRtuTimerRun(&mb00_Obj);
    mbRtuTimerRun(&mb02_Obj);
}

/*******************************************************************************
 * system init
 ******************************************************************************/
void sys_init(void)
{
    sysst.mem_addr_heap = (uint32_t)(&Image$$ARM_LIB_HEAP$$ZI$$Base);
    sysst.mem_addr_stack = (uint32_t)(&Image$$ARM_LIB_STACK$$ZI$$Base);
    sysst.mem_addr_heap_end = (uint32_t)(&Image$$ARM_LIB_HEAP$$ZI$$Limit);
    sysst.mem_addr_stack_end = (uint32_t)(&Image$$ARM_LIB_STACK$$ZI$$Limit);
}
